# Contributor: Nicolas Lorin <androw95220@gmail.com>
# Maintainer:
pkgname=scons
pkgver=4.3.0
pkgrel=0
pkgdesc="Software construction system"
url="https://scons.org/"
arch="noarch"
license="MIT"
depends="python3"
makedepends="py3-setuptools"
checkdepends="xz"
subpackages="$pkgname-doc"
# fetching both sources, because only github tarball has tests
# and only sourceforge tarball has prebuilt manpages
# building the scons manpages requires working scons install...
source="https://github.com/SCons/scons/archive/$pkgver/scons-$pkgver.tar.gz
	https://downloads.sourceforge.net/project/scons/scons/$pkgver/SCons-$pkgver.tar.gz
	dont-install-manpages.patch
	broken-tests.patch
	"

prepare() {
	default_prepare

	# remove failing test
	case $CARCH in
	ppc64le) rm test/builderrors.py ;;
	esac
}

build() {
	python3 setup.py build
}

check() {
	python3 runtest.py -a
}

package() {
	python3 setup.py install --prefix=/usr --root="$pkgdir"

	# find and remove directories containing docbook files
	find "$pkgdir" -name 'docbook' -type d -exec rm -rf {} +

	install -Dm644 \
		"$srcdir"/SCons-$pkgver/scons.1 \
		"$srcdir"/SCons-$pkgver/scons-time.1 \
		"$srcdir"/SCons-$pkgver/sconsign.1 \
		-t "$pkgdir"/usr/share/man/man1/
}

sha512sums="
2d91cf3045797c888d24db38d5b44576e56b271a2c4e9d28d7e16026451865f713990ff9e57fa3e0a1c19603c2d6adbbd1ba36d297c9dcce4db4139fcc51cd62  scons-4.3.0.tar.gz
200e087a0a3de7d92d7da6bdb7f2dc0f5d9ff4908a9d6aef2feab8cacfb2e480b7d88efca8f7a84bd39620db2efceaca14f68e6edbf494b1c28b80e35ed14f2c  SCons-4.3.0.tar.gz
286dbd5230119237b2ef2ece572d70c8b22d78ac71c5ac7a7a23e1c8597ca6379f324293560276777b608eb7b7af070374e8df91b593e6c656d81e13367efccd  dont-install-manpages.patch
aa495ac6dd4d62b14021c852bc98bb0d308cd34960e870eb08b8780c069ece8779a8cd1637c3e5b6d90ff4c223bac99bbb3eda5a87f17ca696a37c8852001358  broken-tests.patch
"
